<template>
  <div>
    <div class="title">隐私政策说明</div>
    <RichText :content="content"></RichText>
    <div class="btns">
      <el-button size="small" @click="$router.go(-1)">返回</el-button>
      <el-button type="primary" size="small" @click="updateAgreement">保存</el-button>
    </div>
  </div>
</template>
<script>
  import RichText from "@/components/RichText.vue";
  import apis from "../../../apis/modules/agreement"
  export default {
    components: {
      RichText,
    },
    data(){
      return {
        type: '2',
        content: ''
      };
    },
    methods: {
      //获取协议
      getAgreement(){
        apis.getAgreement(this.type).then((res) => {
          if (res.code == 200) {
            this.content = res.data.content;
          }
        });
      },
      //修改协议
      updateAgreement(){
        apis.updateAgreement(this.type, this.content).then((res) => {
          if (res.code == 200) {
            this.$message.success('保存成功');
          }
        });
      }
    },
    mounted(){
      this.getAgreement();
    }
  }
</script>
<style>
  .title{
    margin-bottom: 32px;
  }
  .btns{
    margin-top: 32px;
    text-align: center;
  }
</style>